package developerworks.jetty6;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

import java.util.ArrayList;
import java.util.Collection;
import javax.servlet.http.HttpSession;

import org.json.JSONArray;
import org.mortbay.util.ajax.Continuation;


public class SessionListener implements HttpSessionListener {
	
	//private static Collection<HttpSession> sessions = new ArrayList<HttpSession>();;
	
	public void sessionCreated(HttpSessionEvent arg0) {
		//
	}

	public void sessionDestroyed(HttpSessionEvent arg0) {
		System.out.println("     Destroying session");
		Inbox i = (Inbox) arg0.getSession().getAttribute("Inbox");
		System.out.println("     inbox");
		ApplicationAddressBook.removeInbox(i);
		System.out.println("     global");
		
		
		i.user.destroy();
		i.user.sendTo("@"+i.domain());
		
	}
	

}
